home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 3 / Cream of the Crop 3.iso / clipper / ks94an.zip / CHRLIMIT.HDR < prev    next >
Text File  |  1994-04-25  |  2KB  |  73 lines

  1. /******************************************************************************
  2.                  The Klipper Library, for CA-Clipper 5.x
  3.         Copyright (c), 1994, Wallace Information Systems Engineering
  4.  
  5. FUNCTION:
  6.  
  7. _ChrLimit( cVar, cChar, nPercent ) --> lExceedsPercent
  8.  
  9. PARAMETERS:
  10.  
  11. cVar    : String Variable to check
  12. cChar   : Specific character to check
  13. nPercent: Cutoff percentage at which to return TRUE
  14.  
  15. SHORT:
  16.  
  17. Determine if a string is composed of n% or more of any given character.
  18.  
  19. DESCRIPTION:
  20.  
  21. _ChrLimit() checks to see if the specified character cChar composes
  22. nPercent or more of the characters in cVar.  If it does, then the
  23. function returns TRUE. If not, FALSE.
  24.  
  25. If cChar is not specified (is empty() or NIL), then the function returns
  26. TRUE if ANY single character, of all the characters in the string,
  27. composes nPercent or more of the total characters.
  28.  
  29. NOTE:
  30.  
  31. _ChrLimit() is really just a "breaking point" function.  It triggers a true
  32. or false condition in response to certain frequencies of characters in
  33. strings.  It's purpose is not to collect statistical data about char
  34. distribution in a string.  Adding such capability would severely slow the
  35. process down.
  36.  
  37. See _ChrPercent() for a function that does more with the distribution and of
  38. percentages of individual characters in a string.  It will, among other
  39. things, give you the percentage ratio of each character in the string.
  40.  
  41. EXAMPLE:
  42.  
  43. cString = 'ABCDEFGHIJ'
  44.  
  45. ? _ChrLimit(cString,'A',50)    // .F.
  46. ? _ChrLimit(cString,'A',10)    // .T.
  47. ? _ChrLimit(cString,'',20)     // .F.
  48. ? _ChrLimit(cString,,10)       // .T.
  49.  
  50.  
  51. In this last example, ALL of the characters are >= 10% of the total chars.
  52. Notice that without specifying cChar, you do not know WHICH character exceeds
  53. the percentage limit, only that one character does.
  54.  
  55.  
  56. cString := '************ TEXT FILE *************'
  57.  
  58. ? _ChrLimit(cString,,50)   // .T.
  59.  
  60. In this example, the "*" composes 69% of the characters and thus exceeds
  61. our cutoff limit of 50%.
  62.  
  63. ? _ChrLimit(cString," ",50)   // .F.
  64.  
  65. In this example, we specifically asked to check the SPACE character.
  66. It composes only 8% of the total characters.
  67.  
  68. ? _ChrLimit(cString," ",1)   // .T.
  69.  
  70. The three spaces comprise more than 1% of the string's characters.
  71.  
  72. ******************************************************************************/
  73.